package com.lesama.print;

/*
    PrintStream的基本使用：
        1. 创建对象关联文件
            public PrintStream(OutputStream os)
            public PrintStream(File f)
            public PrintStream(File f, String csn)
            public PrintStream(String filepath)
            public PrintStream(String filepath, String csn)
        2. 写出方法
            write(): 写出一个字节，不建议使用，无法原样写入
            print(): 原样写入数据，无换行
            println(): 原样写入数据，带有换行
 */

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;

public class PrintStreamDemo1 {
    public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
        PrintStream ps = new PrintStream(new FileOutputStream("day14\\d.txt", true));
        ps.println("当两颗心开始振动");
        ps.close();
    }

    private static void extracted1() throws FileNotFoundException, UnsupportedEncodingException {
        PrintStream ps = new PrintStream("D:\\c.txt", "gbk");
        ps.println("请你不要再迷恋哥");
        ps.close();
    }

    private static void extracted() throws FileNotFoundException {
        PrintStream ps = new PrintStream("day14\\d.txt");
        ps.println("我会找个天使替我去爱你");
        ps.close();
    }
}